﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Xf.MvcTag.Simple.Db;
using Xf.MvcTag.Simple.Models;
using Xf.MvcTag.UIExt.DataTables;

namespace Xf.MvcTag.Simple.Controllers
{
    public class AdminController : Controller
    {
        DemoDbContext _db;
        public AdminController(DemoDbContext db)
        {
            _db = db;
        }
        public IActionResult Index()
        {
            return View();
        }
        public IActionResult General()
        {
            return View();
        }
        public IActionResult Icons()
        {
            return View();
        }
        public IActionResult Buttons()
        {
            return View();
        }
        public IActionResult Modals()
        {
            return View();
        }

        //Forms
        public IActionResult Forms()
        {
            return View();
        }

        //Tables
        public IActionResult Tables(DtRequest model)
        {
            var x = Request.QueryString;
            var xq = Request.Query;
            var test = model;
            return View();
        }
        public JsonResult TableApi(DtRequest model)
        {
            _db.Persions.Add(new Persion()
            {
                Id = Guid.NewGuid().ToString(),
                Name = "test1"
            });
            _db.SaveChanges();
            return Json(DtResult.Page(model, _db.Persions.ToList()));
        }
        public IActionResult Tables1(string id, string name)
        {
            var x = Request.QueryString;
            var xq = Request.Query;
            var test = id;
            var t = name;
            return View();
        }
    }
}